$(function() {
        $("#lall").empty();
        TU.loading($("#lall"));
        $.get("/welcome/alllogs", function(g) {
                TU.remove_loading($("#lall"));
                $("#lall").html(g);
                
                var h = $("#lall div.log").length;
                if (h > 13) {
                                        //ÏÔÊ¾ÈÕÖ¾¶àÉÙÌõ
                        $("#lall div.log").slice(h - 13).removeClass("hide");
                        setInterval(function() {
                                $("#lall div.log:hidden:last").fadeIn(1000, function() {
                                        if ($("#lall div.log:hidden").length <= 2) {
                                                f()
                                        }
                                });
                                $("#lall div.log:visible:last").remove();
                        }, 5000)
                } else {
                        $("#lall div.log").removeClass("hide");
                }
        }); 


       
            
        var c = 1;
        var e = false;
        var a = "lall";
        $('a[data-toggle="tab"]').on("shown", function(g) {
                b(1);
                e = false;
                a = $(this).attr("href").substring(1);
                if (a == "lall") {
                        $("div.pagination").hide()
                } else {
                        $("div.pagination").show();
                        d(1)
                }
        });
        function f() {
                $.get("/welcome/alllogs", function(g) {
                        $("#lall").prepend(g)
                })
        }
        function d(h) {
 
                h = h || 1;
                var g = 0;
                if (a == "lmy0") {
                        g = 0
                } else {
                        if (a == "lmy1") {
                                g = 1
                        }
                }
               
                $("#lmy" + g).empty();
                TU.loading($("#lmy" + g));
                $.get("/welcome/mylogs/" + h + "/" + g + "/" + Math.random(), function(i) {
						
                        TU.remove_loading($("#lmy" + g));
                        if (i.status == 1) {
						
                                $("#lmy" + g).html(i.data.body);
								
                                e = i.data.count < i.data.page_size ? true : false
							
                        } else {
                                TU.msgbox.alert($("#lmy" + g).offset().top, i.info)
                        }
                }, "json")
        }
        function b(g) {

                c = g;
                $(".pagination a.current").text(g)
        }
        
        $("div.pagination a").click(function() {

                var i = c;
                var g = $(this);
                var h = g.attr("class");
                if ((c == 1 && h == "previous") || (e && h == "next")) {
                        return false
                }
                if (h == "previous") {
                        i = c - 1
                } else {
                        if (h == "next") {
                                i = c + 1
                        }
                }
                i = i > 0 ? i : 1;

                b(i);
                d(i);
        })
});